home *** CD-ROM | disk | FTP | other *** search
/ NeXTSTEP 3.3 (Developer)…68k, x86, SPARC, PA-RISC] / NeXTSTEP 3.3 Dev Intel.iso / NextDeveloper / Headers / remote / transport.h < prev   
Text File  |  1992-05-29  |  3KB  |  68 lines

  1. /* transport.h
  2.  * encoding/decoding protocols for DistributedObjects
  3.  * Copyright 1992, NeXT Computer, Inc.
  4.  */
  5.  
  6. #import <objc/Object.h>
  7. #import <mach/port.h>
  8.  
  9. /* these are the general encoding/decoding protocols implemented by all objective-C message buffering/delivery classes */
  10.  
  11. /* The general scheme is that Proxys will encode a method and its arguments onto a portal, and/or decode requests or replies from a portal.  The encoding/decoding protocol allows for potentially different implementations of portals, such as an in memory queue or a TCP channel or a System V STREAMS version... or whatever your favorite connection paradigm is.  Note that the treatment of MACH memory and MACH ports would need to be emulated very closely in any underlying implementation. */
  12.  
  13. @protocol NXEncoding
  14. // encode an objc (parameter) type
  15. - encodeData:(void *)data ofType:(const char *)type;
  16.  
  17. // encoding methods for transcribing custom objects
  18. - encodeBytes:(const void *)bytes count:(int)count;
  19. - encodeVM:(const void *)bytes count:(int)count;
  20. - encodeMachPort:(port_t)port;
  21. - encodeObject:anObject;    // send a ref to the object across
  22. - encodeObjectBycopy:anObject;  // copy the object across
  23.  
  24. @end
  25.  
  26. @protocol NXDecoding
  27. // decode an objc (parameter) type
  28. - decodeData:(void *)d ofType:(const char *)t;
  29.  
  30. // decoding methods for transcribing custom objects
  31. - decodeBytes:(void *)bytes count:(int)count;
  32. - decodeVM:(void **)bytes count:(int *)count;
  33. - decodeMachPort:(port_t *)pp;
  34. - (id) decodeObject;                    // returns decoded object
  35. @end
  36.  
  37. /* Objects that encode themselves "on the wire" need to implement the following methods */
  38.  
  39. @class NXConnection;
  40.  
  41. @protocol NXTransport
  42. // This method is called for every object before encoding.
  43. // It should return self if the object always transcribes itself.
  44. // If the object wants to conditionally transcribe itself depending
  45. // on whether the bycopy keyword is present in the methods protocol
  46. // description, it should return self if isBycopy is true, and
  47. // return [super encodeRemotelyFor...] if false.
  48. // If the object wants another object to be sent, it should return that
  49. // object.
  50. // Setting *flagp to true will cause the returned object to be freed after encoding.
  51. - encodeRemotelyFor:(NXConnection *)connection freeAfterEncoding:(BOOL *)flagp isBycopy:(BOOL)isBycopy;
  52.  
  53. // The object should encode itself on the portal
  54. - encodeUsing:(id <NXEncoding>)portal;
  55. // The object should initialize itself from the portal
  56. - decodeUsing:(id <NXDecoding>)portal;
  57. @end
  58.  
  59.  
  60. /* Object provides an implementation that creates NXProxies on the other side */
  61.  
  62. @interface Object (Object_MakeRemote)
  63. - encodeRemotelyFor:(NXConnection *)connection freeAfterEncoding:(BOOL *)flagp isBycopy:(BOOL)isBycopy;
  64. @end
  65.  
  66.  
  67.  
  68.